package com.edgardeng.education.mapper;

import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.edgardeng.education.entity.Student;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;

/**
 * <p>
 * 学生 Mapper 接口
 * </p>
 *
 * @author edgardeng
 * @since 2020-04-28
 */
public interface StudentMapper extends BaseMapper<Student> {

    // 使用使用条件构造器Wrapper 来自定义sql
    @Select("select * from t_student ${ew.customSqlSegment}")
    List<Student> getPart(@Param(Constants.WRAPPER) Wrapper wrapper);

    List<Student> getPartList(@Param(Constants.WRAPPER) Wrapper wrapper);

    @Select("select student.*, school.* from t_student student join t_school school on school.id = student.school_id where student.id = ${id}")
    Student selectWithSchoolClass(Long id);

}
